function [ d ] = myPoly( p, pv )
%MYPOLY Summary of this function goes here
%   Detailed explanation goes here

global tri;

% tri

fv = struct('vertices', pv, 'faces', tri);

in = inpolyhedron(fv, p);

ds=dsegment3(p,pv);
%ds=zeros(np,nvs);
%for iv=1:nvs
%  ds(:,iv)=donesegment(p,pv(iv:iv+1,:));
%end
d=min(ds,[],2);

d=(-1).^(in).*d;

end

